import request from '@/router/axios';

export const getList = (current, size, params) => {
    return request({
        url: '/api/mes-product/qms-inspection-template/page',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}

export const getDetail = (id) => {
    return request({
        url: '/api/mes-product/qms-inspection-template/detail',
        method: 'get',
        params: {
            id
        }
    })
}

export const remove = (ids) => {
    return request({
        url: '/api/mes-product/qms-inspection-template/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}

//新增或修改检验模板
export const save = (row) => {
    return request({
        url: '/api/mes-product/qms-inspection-template/submit',
        method: 'post',
        data: row
    })
}



//新增或修改模板的检查项及检查项详情
export const saveInspection = (row) => {
    return request({
        url: '/api/mes-product/qms-inspection-template/saveInspection',
        method: 'post',
        data: row
    })
}

/**
 * 根据模板id查询选择的检验树
 * @param {string} templateId
 * @returns
 */
export const getTreeById = (templateId) => {
    return request({
        url: '/api/mes-product/qms-inspection-item/selectTree',
        method: 'get',
        params: {
            templateId
        }
    })
}

/**
 * 获取检验项明细
 */
export const getInspectionTemattribute = (current, size, params) => {
    return request({
        url: '/api/mes-product/qms-inspection-item-attribute/page',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}

/**
 * 模板应用提交
 */
//新增或修改检验模板
export const templateSubmit = (data) => {
    return request({
        url: '/api/mes-product/qms-inspection-template/object-application',
        method: 'post',
        data
    })
}

